package com.example.springbootjpa.controller;

import com.example.springbootjpa.model.Teacher;
import com.example.springbootjpa.service.TeacherService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class TeacherController {
    @Resource
    private TeacherService service;

    @GetMapping("/list")
    public List<Teacher> list() {
        return service.selectAll();
    }

    @PostMapping("/add")
    public void add(Teacher teacher) {
        service.add(teacher);
    }

    @PutMapping("/update")
    public void update(Teacher teacher) {
        service.update(teacher);
    }

    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") Integer id) {
        service.delete(id);
    }

}
